﻿using System;
using System.Drawing.Design;
using System.Windows.Forms;
using Argos.Windows.Forms;
using System.Net;

namespace Argos.Design
{
	public class IPAddressTypeEditor : UITypeEditor
	{

		public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
		{

			using (IPAddressEditorDialog dlg = new IPAddressEditorDialog())
			{
				dlg.SelectedAddress = value as IPAddress;

				if (dlg.ShowDialog() == DialogResult.OK)
				{
					return dlg.SelectedAddress;
				}
			}

			return value;
		}

		public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
		{
			return UITypeEditorEditStyle.Modal;
		}

	}
}
